
<template>
  <div class="box">
    
    <div class="uploadApplication">
        <p>入库备案申请表</p>
        <div class="upLoadImg">
          <upload @beforeUpload="beforeUpload" @res="getRes" :accept="'.pdf'" />
        </div>
        
    </div>
  </div>
</template>

<script>
import upload from "@/components/upload";
import xTable from '@/views/xtable.vue'
import { upImg } from "@/api/upImg";

import { uploadProjectStoringRecordTable } from "@/api/storageForRecordInfo";
export default {
  components: {
    upload
  },
  data() {
    return {
      uploadText:'上传',
      fileData:{
        fileName:'',  
        fileUrl:'',  
        id:'',
      },
     
    };
  },
 
  methods:{
    //上传前
    beforeUpload(){
    },
    //上传后
    getRes(res){
      console.log(res)
      this.fileData.fileName=res.data.fileName
      this.fileData.fileUrl=res.data.filePath
      this.fileData.id=res.data.id
      let obj={
        projectId:localStorage.getItem("projectId"),
        projectStoringRecordTableId:this.fileData.id
      }
      uploadProjectStoringRecordTable(obj).then(res=>{
        if(res.code==1000){
            this.uploadText="上传"
            this.$message({
            message:'上传成功，请继续下一步操作',
            type:'success'
          })
        }
        
      })
    },
    // changeFile(file){//文件上传
    //   this.uploadText="上传中.."
    //   upImg(file).then(res=>{
    //     console.log(res,'res')
    //     this.fileData.fileName=res.data.fileName
    //     this.fileData.fileUrl=res.data.filePath
    //     this.fileData.id=res.data.id
       
    //     if(res.code==1000){
    //       let obj={
    //         projectId:localStorage.getItem("projectId"),
    //         projectStoringRecordTableId:this.fileData.id
    //       }
    //       uploadProjectStoringRecordTable(obj).then(res=>{
    //         if(res.code==1000){
    //            this.uploadText="上传"
    //            this.$message({
    //             message:'上传成功，请继续下一步操作',
    //             type:'success'
    //           })
    //         }
            
    //       })
    //     }
    //   })
    // },
  }
};
</script>

<style lang="scss">
.form .el-input__inner {
  width: 200px;
}
</style>

<style lang="scss" scoped>
.upLoadImg {
  display: flex;
  align-items: center;
  p{
    margin-left:20px; 
  }
}
  .box{
    margin: 30px;
    .uploadApplication{
        margin: 30px;
        display: flex;
        align-items: center;
        p{
            font-size: 13px;
            color: #444;
            font-weight: bold;
            margin-right: 20px;
        }
    }
  }
</style>
